package com.acme.bankapp.domain.client;

import com.acme.bankapp.domain.account.Account;

public class Client {
    	static private int counter = 0;
    	
    	private final int clientID = counter++; 
    	
	private Account account;

	private final Gender gender;

	private String name;

	public Client(String name, Gender gender, Account account) {
		super();
		this.account = account;
		this.name = name;
		this.gender = gender;
	}

	public Account getAccount() {
		return account;
	}

	public String getClientSalutation() {
		return gender + getName();
	}

	public Gender getGender() {
		return gender;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return getClientSalutation();
	}

	@Override
	public int hashCode() {
	    final int prime = 31;
	    int result = prime + clientID;
	    return result;
	}

	@Override
	public boolean equals(Object obj) {
	    if (this == obj)
		return true;
	    if (obj == null)
		return false;
	    if (getClass() != obj.getClass())
		return false;
	    Client other = (Client) obj;
	    if (account == null) {
		if (other.account != null)
		    return false;
	    } else if (!account.equals(other.account))
		return false;
	    if (gender != other.gender)
		return false;
	    if (name == null) {
		if (other.name != null)
		    return false;
	    } else if (!name.equals(other.name))
		return false;
		if (clientID != other.clientID) {
		    return false;
		}
	    return true;
	}
	
}
